package top.liujiachen.springboot.shiro.dao.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import top.liujiachen.springboot.shiro.dao.IUserDao;
import top.liujiachen.springboot.shiro.entity.SysUser;
import top.liujiachen.springboot.shiro.mapper.SysUserMapper;

@Service
public class UserDao extends ServiceImpl<SysUserMapper, SysUser> implements IUserDao {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Override
    public SysUser getByUsername(String username) {
        SysUser user = new SysUser();
        if (StringUtils.isNotBlank(username)) {
            Wrapper wrapper = lambdaQuery().eq(SysUser::getUsername, username).getWrapper();
            user = getBaseMapper().selectOne(wrapper);
        }
        return user;
    }
}
